package com.whenjun.service.core;

import com.alibaba.fastjson.JSONObject;
import com.whenjun.common.LoggerParent;
import com.whenjun.dto.req.EventReq;
import com.whenjun.util.ArtemisPostUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Auther: shirley
 * @Date: 2022/7/10 10:39
 * @Description:
 */
@Service
public class EventService extends LoggerParent {

    @Autowired
    private ArtemisPostUtil artemisPostUtil;

    /**
     * 按事件类型订阅事件
     * @param eventReq
     */
    public void eventSubscriptionByEventTypes(EventReq eventReq) {
        JSONObject jsonObject = (JSONObject) artemisPostUtil.callPostApi("/api/eventService/v1/eventSubscriptionByEventTypes", eventReq);

        log.info("按事件类型订阅事件:" + jsonObject);
    }

    /**
     * 按事件类型取消订阅事件
     * @param eventReq
     */
    public void eventUnSubscriptionByEventTypes(EventReq eventReq) {
        JSONObject jsonObject = (JSONObject) artemisPostUtil.callPostApi("/api/eventService/v1/eventUnSubscriptionByEventTypes", eventReq);
        log.info("按事件类型取消订阅事件:" + jsonObject);
    }

    /**
     * 查询订阅事件
     * @return
     */
    public JSONObject eventSubscriptionView() {
        JSONObject jsonObject =(JSONObject) artemisPostUtil.callPostApi("/api/eventService/v1/eventSubscriptionView", null);
        return jsonObject;
    }
}
